const { Menu, BrowserWindow } = require("electron");
const Types = require("../../const/eventName");

function handleContextEvent(event, para) {
  const template = [
    {
      label: "打开",
      click: () => {
        event.sender.send(Types.OPENFILE, para);
      },
    },
    {
      label: "重命名",
      click: () => {
        event.sender.send(Types.EDITFILE, para);
      },
    },
    {
      label: "删除",
      click: () => {
        event.sender.send(Types.DELETEFILE, para);
      },
    },
  ];
  const menu = Menu.buildFromTemplate(template);
  menu.popup(BrowserWindow.fromWebContents(event.sender));
}

module.exports = handleContextEvent;
